package com.example.mapper;

import com.example.pojo.DO.EmpDO;
import com.example.pojo.EemQueryParam;
import com.example.pojo.VO.EmpVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * 员工基本信息
 */
@Mapper
public interface EmpMapper {
//原始分页查询实现语句
    /**
     * 查询总记录数
     *
     */
//    @Select("select count(*) from emp e left join dept d on e.dept_id = d.id;")
//    public Long count();
    /**
     * 分页查询
     */
    //@Select("select e.*, d.name as deptName from emp as e " +
    //        "left join dept as d on e.dept_id = d.id " +
    //        "order by e.update_time DESC limit #{start}, #{pageSize};")
    //public List<Emp> list(Integer start, Integer pageSize);


    /**
     *分页查询
     */
    //@Select("select e.*, d.name as deptName from emp as e left join dept as d on e.dept_id = d.id order by e.update_time DESC")


    List<EmpVO> list(EemQueryParam empQueryParam);



    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username, password, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values(#{username}, #{password}, #{name}, #{gender}, #{phone}, #{job}, #{salary}, #{image}, #{entryDate}, #{deptId}, #{createTime}, #{updateTime});")
    void insert(EmpDO emp);
    @Select("select * from emp where id = #{id};")
    EmpDO getEmpInfoById(Integer id);


    void updateByEmpId(EmpDO empDO);

    void deleteByIds(List<Integer> ids);

    /**
     * 统计员工人数
     */
    @MapKey("job")
    List<Map<String, Object>> countEmpJobData();
}
